# Read Annual concentration by Monitors data-----------------

filenames_daily <- list.files(paste("data/raw/aqs/",poll, sep=""))

dir_daily <- paste(wd,"/data/raw/aqs/",poll,"/", filenames_daily, sep="")

data_daily <- vector("list", length(dir_daily))
for (i in 1:length(filenames_daily)) {
  zipFileInfo <- unzip(dir_daily[i], list=TRUE)
  data_daily[[i]] <- read.csv(unz(dir_daily[i], as.character(zipFileInfo$Name)), stringsAsFactors = F)
}

# Exclude Mexico(80) and Canada(CC)
# Add GEOID10 to Monitor X Daily
# Add year variable
assign(paste("data_daily_comb", poll, sep="_"), rbindlist(data_daily) %>% 
  dplyr::filter(!(State.Code %in% c("80", "CC"))) %>%
  dplyr::mutate(TrueDate = as.Date(Date.Local),
                GEOID10 = as.numeric(State.Code)*1000 + as.numeric(County.Code),
                year = lubridate::year(TrueDate)))

save(list=paste("data_daily_comb", poll, sep = "_"), file = paste("data/interim/", poll, "/data_daily_comb_", poll,".RData",sep=""))

load(file = paste("data/interim/", poll, "/data_daily_comb_", poll,".RData", sep=""))
